home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr50 / pbwiz17.zip / CALC.BAS < prev    next >
BASIC Source File  |  1993-06-05  |  2KB  |  67 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |         PBWIZ  Copyright (c) 1991-1993  Thomas G. Hanlin III         |
  4. '   |                                                                      |
  5. '   |                      PowerBASIC Wizard's Library                     |
  6. '   |                                                                      |
  7. '   +----------------------------------------------------------------------+
  8.  
  9.    $DIM ARRAY
  10.    $STACK 8192
  11.  
  12.    DECLARE SUB Evaluate (STRING, SINGLE, INTEGER)
  13.  
  14.    $LINK "pbwiz.pbl"
  15.  
  16.    DEFINT A-Z
  17.  
  18.    Expr$ = COMMAND$
  19.  
  20.    Evaluate Expr$, Result!, ErrCode
  21.  
  22.    SELECT CASE ErrCode
  23.       CASE 0
  24.          PRINT Expr$; " =";
  25.          IF ABS(Result!) = Result! THEN
  26.             PRINT Result!
  27.          ELSE
  28.             PRINT " "; Result!
  29.          END IF
  30.       CASE 1
  31.          PRINT "Argument expected"
  32.       CASE 2
  33.          PRINT "Missing number"
  34.       CASE 3
  35.          PRINT "Unknown function"
  36.       CASE 4
  37.          PRINT "Unbalanced parentheses"
  38.       CASE 5
  39.          PRINT "Imaginary number"
  40.       CASE 8
  41.          PRINT "CALC  Copyright (c) 1991-1993  Thomas G. Hanlin III"
  42.          PRINT
  43.          PRINT "Syntax:"
  44.          PRINT "   CALC expression"
  45.          PRINT
  46.          PRINT "Expressions may use the following operators:"
  47.          PRINT "   +      add"
  48.          PRINT "   /      divide"
  49.          PRINT "   *      multiply"
  50.          PRINT "   -      subtract"
  51.          PRINT "   ^      raise to a power (** also works)"
  52.          PRINT
  53.          PRINT "A number of functions are also provided:"
  54.          PRINT "   ABS    absolute value         INT    integer"
  55.          PRINT "   ACOS   inverse cosine         LOG    natural log"
  56.          PRINT "   ASIN   inverse sine           PI     3.141593"
  57.          PRINT "   ATAN   inverse tangent        SIN    sine"
  58.          PRINT "   COS    cosine                 SQR    square root"
  59.          PRINT "   FRAC   fraction               TAN    tangent"
  60.          PRINT
  61.          PRINT "Trig functions expect angles in radians."
  62.       CASE 9
  63.          PRINT "Division by zero"
  64.       CASE ELSE
  65.          PRINT "Error"
  66.    END SELECT
  67.